<%@ page contentType="text/html;charset=utf-8" %>
<%@ page language="java" import="java.util.*,org.jamwiki.utils.Utilities,java.io.*,org.jamwiki.Environment" %>
<jsp:directive.page import="java.net.URLEncoder"/> 
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript" src="ntkoocx.js"></SCRIPT>
<TITLE>广东韶关移动知识维客管理系统-在线编辑</TITLE>
<style>
button.op{
width:90px;
background-color:#9DC2DB;
border:1px #EEEEEE solid;
cursor: hand;
}
</style>
</HEAD>
<%
  String server = request.getServerName();
  int port = request.getServerPort();
  String hostport = "http://"+server+":"+port+request.getContextPath()+"/en/Image:";
  String docNamePath = request.getParameter("namepath");
  String categoryId = request.getParameter("categoryId");
  String docType= request.getParameter("docType");
  String filename = "";
  if ( null == docNamePath) //新文档
  {
  	docNamePath = "";
  	Calendar rightNow = Calendar.getInstance();
  	filename = (new Integer(rightNow.get(Calendar.MONTH))).toString()+ rightNow.get(Calendar.YEAR) 
  		+ rightNow.get(Calendar.DAY_OF_MONTH)
  		+ rightNow.get(Calendar.MINUTE) + rightNow.get(Calendar.SECOND)+"."+docType; //缺省文件名
  	filename = request.getParameter("fileName")+"."+docType;
    if(docType.equals("vsd")){
    	 docNamePath = request.getRealPath("/")+"temp/template.vsd" ;
    	 docNamePath = docNamePath.replace("\\\\","\\");
    	 docNamePath = docNamePath.replace("\\","/");  
    	 
     }
  }else{
    
    File file = new File(docNamePath);
    filename=file.getName();
    String[] temp = filename.split("[-]");
    filename = temp[0]+"."+temp[1].substring(temp[1].lastIndexOf(".")+1);
    String baseUploadPath = Environment.getValue("file-dir-full-path");
    String relativeUploadPath=Environment.getValue("file-dir-relative-path");
    docNamePath = baseUploadPath+"/"+docNamePath.replace((CharSequence)relativeUploadPath, "");
    docNamePath = docNamePath.replace("\\\\","\\");
    docNamePath = docNamePath.replace("\\","/");  
  }
%>
<BODY leftMargin=0 topMargin=0 onLoad='javascript:TANGER_OCX_OpenDoc("<%=docNamePath%>","<%=docType %>")'>
<center>
<FORM id="myForm" METHOD="POST" ENCTYPE="multipart/form-data" ACTION="<%=request.getContextPath() %>/en/Special:Upload">
<TABLE BORDER=0 width ="80%" align="center" style="display:none">	
	<tr>
	    <td width="30%" align="center">文件名：
	    <textarea style="display:none" name="description" rows="6" cols="80" id="uploadDescription" ></textarea>	
	    <input style="display:none" name="hostport" id="hostport" value ='<%=hostport %>'/>
	    <input style="display:none" name="name" id="name" value ="<%=filename%>"/>
	    <input style="display:none" name="categoryId" id="categoryId" value ="<%=categoryId%>"/>
	    </td>
		<td width="40%" align="center"><input id="filename" name="filename" MAXLENGTH=50 size=50 value="<%=Utilities.StringToUnicode(filename)%>"></td>
		<td width="30%" align="center"><INPUT type=BUTTON VALUE="上传" onclick="TANGER_OCX_SaveEditToServer();"> <INPUT type=BUTTON VALUE="关闭" onclick="javascript:window.close();"></td>
	</tr>
</TABLE>  
<TABLE style="display:none"  BORDER=0 width ="100%" align="center" cellpadding=0 cellspacing=0 bgcolor="#9dc2db">	
	<tr>
	    <td align="center" height="40">
          <button class="op" onclick="TANGER_OCX_SaveEditToServer();">保存</button> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <button class="op" onclick="window.close();">关闭</button>
       </td>
	</tr>
</TABLE>  
<table width=100% height=700 border=0 cellpadding=0 cellspacing=0 style="border:1px #9dc2db solid">
<tr width=100%>
<td width=100%>		
	<script src="<%=request.getContextPath() %>/js/ntkoGenObj.js"></script> 
	<!-- 以下函数相应控件的两个事件:OnDocumentClosed,和OnDocumentOpened -->
	<script language="JScript" for=TANGER_OCX_OBJ event="OnDocumentClosed()">
		TANGER_OCX_OnDocumentClosed(); 
	</script>
	<script language="JScript" for=TANGER_OCX_OBJ event="OnDocumentOpened(TANGER_OCX_str,TANGER_OCX_OBJ)">
		TANGER_OCX_OnDocumentOpened(TANGER_OCX_str,TANGER_OCX_OBJ);
	</script>
</td>
<td valign=top width=40 style="display: none" >
    <button class="op" onclick="TANGER_OCX_SaveEditToServer();">保存</button>
	<button class="op" onclick="window.close();">关闭</button>
	 
</td>
</tr></table>	
</FORM>
</center>
</BODY>
</HTML>